Skip to content

Add advanced request usage query to display remaining quota via the web version.#48

Merged
ericc-ch merged 1 commit into
ericc-ch:masterfrom
Asheblog:master
Jun 22, 2025
Merged

Add advanced request usage query to display remaining quota via the web version.#48
ericc-ch merged 1 commit into
ericc-ch:masterfrom
Asheblog:master

Conversation

@Asheblog
Copy link
Copy Markdown

@Asheblog Asheblog commented Jun 21, 2025

Referenced the project at https://github.com/uheej0625/copilot-usage-viewer and merged it into this project.
You can view the webpage at http://localhost:4141/public/usage.html.

  • Copilot Usage Viewer: Integrated web interface to view your GitHub Copilot usage statistics and quota information
  • Token Display: View the current Copilot token being used by the API
  • Real-time Monitoring: Track your usage and remaining quotas in real-time

image
image

Copilot AI review requested due to automatic review settings June 21, 2025 15:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR integrates a web-based Copilot Usage Viewer with real-time monitoring and token display features to enhance API usability.

  • Added a batch file to bootstrap the server and automatically open the usage viewer page
  • Created new endpoints and services for fetching and displaying Copilot usage statistics and tokens
  • Updated the server routing and documentation to support these new features

Reviewed Changes

Copilot reviewed 8 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
start.bat Adds a batch script to install dependencies and launch the server
src/services/github/get-copilot-usage.ts Implements API call for Copilot usage data retrieval
src/server.ts Updates server configuration with additional static and API routes
src/routes/usage/route.ts Defines new API endpoint for fetching usage data
src/routes/token/route.ts Defines new API endpoint for fetching token information
src/main.ts Modifies startup sequence to include token setup and adds log details
src/lib/token.ts Logs token retrieval and refresh events
README.md Documents the new usage viewer and monitoring endpoints

Comment thread src/main.ts

await setupCopilotToken()
await cacheModels()
} await setupCopilotToken()
Copy link

Copilot AI Jun 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider placing the 'await setupCopilotToken()' call on a new line for improved readability and to avoid any potential parsing ambiguities.

Suggested change
} await setupCopilotToken()
}
await setupCopilotToken()

Copilot uses AI. Check for mistakes.
@ericc-ch
Copy link
Copy Markdown
Owner

Hey this looks cool, thank you!
Didn't know we can fetch usage info like that

I'm not sure about displaying the token automatically though
Not really a security issue, but I feel uncomfortable. Feels like I can just accidentally expose it
What about adding a separate CLI subcommand to show the token?

Also, do you mind if I spice up the HTML a bit?
I'll merge the PR and work it myself

Other than that, looks good!
Again, thank you so much

@Asheblog
Copy link
Copy Markdown
Author

Hey this looks cool, thank you!嘿,这看起来很酷,谢谢! Didn't know we can fetch usage info like that不知道我们可以这样获取使用信息

I'm not sure about displaying the token automatically though但我不确定是否会自动显示令牌 Not really a security issue, but I feel uncomfortable. Feels like I can just accidentally expose it不算什么安全问题,但我觉得有点不舒服。感觉我可能会不小心暴露它。 What about adding a separate CLI subcommand to show the token?添加单独的 CLI 子命令来显示令牌怎么样?

Also, do you mind if I spice up the HTML a bit?另外,你介意我给 HTML 加点料吗? I'll merge the PR and work it myself我会合并 PR 并自己处理

Other than that, looks good!除此之外,看起来不错! Again, thank you so much再次感谢

Of course it can! I also happened to see the author of this project share on Reddit, and thought it could be incorporated into this project to facilitate real-time viewing of advanced request consumption. If I can help you, I am very happy!

@ericc-ch ericc-ch merged commit 636f90c into ericc-ch:master Jun 22, 2025
hao1939 pushed a commit to hao1939/copilot-api that referenced this pull request Nov 22, 2025
Add advanced request usage query to display remaining quota via the web version.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants